package cn.chinasyq.photoquan.util;

/**
 * Created by 一搏 on 2015/11/28.
 */

import java.math.BigDecimal;
import java.text.DecimalFormat;


public class FormatUtil {
    private static final DecimalFormat priceformat = new DecimalFormat("0");
    private static final DecimalFormat scoreformat = new DecimalFormat("0.0");
    private static final DecimalFormat distanceformat = new DecimalFormat("0.00km");
    private static final DecimalFormat shopPriceFormat = new DecimalFormat("0.00");
    //千位分割符
    private static final DecimalFormat numforthousandformat = new DecimalFormat("##,###,###");
    private static final DecimalFormat moneyForThousandFormat = new DecimalFormat("#,##0.00");
    //千位分割符
    private static final DecimalFormat priceFormathasrmb = new DecimalFormat("￥0.00");

    public static DecimalFormat obtainPriceFormat() {
        return priceformat;
    }

    public static DecimalFormat obtainScoreFormat() {
        return scoreformat;
    }

    public static DecimalFormat obtainDistanceFormate() {
        return distanceformat;
    }

    public static DecimalFormat obtainNumForThousandFormate() {
        return numforthousandformat;
    }
    public static DecimalFormat obtainMoneyForThousandFormat() {
        return moneyForThousandFormat;
    }

    public static String obtainShopPriceFormat(Object object) {
        if (object instanceof String){
            return shopPriceFormat.format(Double.valueOf((String)object));
        }
        return shopPriceFormat.format(object);
    }
    public static DecimalFormat bookingPriceFormat = new DecimalFormat("0.00");
    public static DecimalFormat obtainPriceFormathasrmb() {
        return priceFormathasrmb;
    }

    public static float obtainTotalPrice(float price){
        BigDecimal b  =   new BigDecimal(price);
        return b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
    }
}

